﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using FrameWorkSong;

namespace FrameWorkSong
{
    public class DrawGizmos : Singleton<DrawGizmos>
    {
        public override void OnBeforeDestroy() { }
        public List<Vector3> CurvePoints = new List<Vector3>();
        public bool IsLine = true;
        public bool IsPoint = true;
        public float Radius = 1;
        public Color LineColor = Color.green;
        public Color PointColor = Color.white;
        public int cont = 1;
        private void OnDrawGizmos()
        {
            //绘制

            if (CurvePoints.Count >= 2)
            {
                if (IsLine)
                {
                    Gizmos.color = LineColor;
                    for (int i = 0; i < CurvePoints.Count - 1; i+= cont)
                    {
                        Gizmos.DrawLine(CurvePoints[i], CurvePoints[i + 1]);
                    }
                }
                if (IsPoint)
                {
                    Gizmos.color = PointColor;
                    //点密度
                    foreach (var item in CurvePoints)
                    {
                        Gizmos.DrawSphere(item, Radius);
                    }
                }
            }
        }

    }
    public partial class MonoBehaviourSimplify
    {
        /// <summary>
        /// 画参考线
        /// </summary>
        /// <param name="vector3s">点组</param>
        /// <param name="color">线颜色</param>
        /// <param name="iscont">是否连续</param>
        public void DebugLine(List<Vector3> vector3s, Color color, bool iscont)
        {
            if (vector3s.Count>=2)
            {
                DrawGizmos drawGizmos = DrawGizmos.Instance;
                drawGizmos.CurvePoints = vector3s;
                drawGizmos.LineColor = color;
                if (iscont)
                {
                    drawGizmos.cont = 1;
                }
                else
                {
                    drawGizmos.cont =2;
                }
                drawGizmos.IsPoint = false;
            }
        }
        /// <summary>
        /// 画参考线
        /// </summary>
        /// <param name="vector3s">点组</param>
        /// <param name="iscont">是否连续</param>
        public void DebugLine(List<Vector3> vector3s, bool iscont)
        {
            DebugLine(vector3s, Color.green, iscont);
        }
        /// <summary>
        /// 画参考线
        /// </summary>
        /// <param name="vector3s">点组</param>
        public void DebugLine(List<Vector3> vector3s)
        {
            DebugLine(vector3s, Color.green, true);
        }
        /// <summary>
        /// 画参考点
        /// </summary>
        /// <param name="vector3s">点组</param>
        /// <param name="color">点颜色</param>
        public void DebugPoint(List<Vector3> vector3s, Color color)
        {
            if (vector3s.Count >= 1)
            {
                DrawGizmos drawGizmos = DrawGizmos.Instance;
                drawGizmos.CurvePoints = vector3s;
                drawGizmos.PointColor = color;
                drawGizmos.IsLine = false;
            }
      
        }
        /// <summary>
        /// 画参考点
        /// </summary>
        /// <param name="vector3s">点组</param>
        public void DebugPoint(List<Vector3> vector3s)
        {
            DebugPoint(vector3s, Color.green);
        }
    }
}
